package com.ngc.mall.controller;

import com.ngc.mall.common.configure.response.ResponseResult;
import com.ngc.mall.domain.SpuDomain;
import com.ngc.mall.service.ISpuService;
import com.ngc.mall.vo.PagingVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private ISpuService iSpuService;

    @GetMapping("")
    @ApiOperation("模糊搜索")
    public ResponseResult<PagingVO<SpuDomain>> search(@RequestParam(name="q") String q, @RequestParam(name = "start", defaultValue = "0")
            Integer start, @RequestParam(name = "count", defaultValue = "8")
                                                           Integer count){
        return ResponseResult.success(iSpuService.findByTitleLikeAndSubTitleLike(q,start,count));
    }
}
